package com.billdowney.entity.base;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import io.swagger.annotations.ApiModelProperty;

/**
 * @Description: 所有表的基础类
 * @author: 唐路钧
 * @date: 2019年1月8日 上午9:48:30
 */
@MappedSuperclass
public class BaseEntityProperty implements Serializable {

	private static final long serialVersionUID = 2678930970586104752L;

	@Column(length = 10, insertable = false)
	@ColumnDefault("'using'")
	@ApiModelProperty(value = "数据状态", notes = "默认为可用状态")
	@Enumerated(EnumType.STRING)
	private EntityStatus status;

	@ApiModelProperty(value = "创建时间", notes = "默认为实例创建时间")
	@Column(updatable = false)
	// @Column(insertable = false, columnDefinition = "datetime DEFAULT
	// CURRENT_TIMESTAMP")
	@Temporal(TemporalType.TIMESTAMP)
	@CreationTimestamp
	private Date createDate;

	@ApiModelProperty(value = "修改时间")
	@Column(insertable = false)
	// @Column(updatable = false, columnDefinition = "datetime DEFAULT
	// CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
	@Temporal(TemporalType.TIMESTAMP)
	@UpdateTimestamp
	private Date updateDate;

	@Column(length = 200)
	@ApiModelProperty(value = "备注")
	private String note;

	public EntityStatus getStatus() {
		return status;
	}

	public void setStatus(EntityStatus status) {
		this.status = status;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	@Override
	public String toString() {
		return "BaseEntityProperty [status=" + status + ", createDate=" + createDate + ", updateDate=" + updateDate
				+ ", note=" + note + "]";
	}

}
